#pragma once

#include "RaceState.h"
#include <vector>

class ActionObject;
class Gate;
class IRaceController;
class AIAgent;


class Race : public IRaceState
{
private:
   IRaceController& m_raceController;
   const std::vector<ActionObject*>& m_activePlayers;
   const std::vector<Gate*>& m_gates;
   const std::vector<AIAgent*>& m_aiAgents;

public:
   Race(IRaceController& raceController,
        const std::vector<ActionObject*>& activePlayers,
        const std::vector<Gate*>& gates,
        const std::vector<AIAgent*>& aiAgents);

   void update(float timeElapsed);

   void activate();

   void deactivate();

   void processInput(UCHAR* keyBuffer, float timeElapsed);

private:
   void checkGatesCrossing();

   void checkVictoryConditions();

   void getNextGateNum(UINT& gateNum);

   void triggerMovement(UCHAR* keyBuffer, float timeElapsed);

   void triggerRotation(UCHAR* keyBuffer, float timeElapsed);

   void triggerActions(UCHAR* keyBuffer);
};